package com.isorf.controller;

import com.isorf.service.adminservice;
import com.isorf.util.responseresult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "管理员登录接口")
@RequestMapping("/admin")
@RestController
public class admincontroller {
    @Autowired
    private adminservice adminservice;

    @PostMapping("/login")  // 明确指定POST方法
    public responseresult<Boolean> login(@RequestBody Map<String, String> request) {
        String username = request.get("username");
        String password = request.get("password");

        // 添加调试日志
        System.out.println("收到登录请求:");
        System.out.println("用户名: " + username);
        System.out.println("密码: " + password);

        Boolean result = adminservice.login(username, password);

        System.out.println("登录结果: " + result);

        if (result) {
            return responseresult.success(responseresult.SUCCESS, "登录成功", result);
        } else {
            return responseresult.failure(responseresult.FAILED, "登录失败");
        }
    }
}